#!/bin/bash
source src/conf/config.conf

cd $tftp_dir
pf_url=http://pfsense.mirrors.ovh.net/pfsense.org/downloads/

echo " Downloading  PFsense ..."

    for ARCH in i386 amd64; do
        mkdir -p "pfsense/${ARCH}"

wget -q -c $pf_url/pfSense-LiveCD-2.0.3-RELEASE-i386-20130412-1022.iso.gz && tar -zxvf pfSense-LiveCD-2.0.3-RELEASE-i386-20130412-1022.iso.gz -C pfsense/i386/

wget -q -c $pf_url/pfSense-LiveCD-2.0.3-RELEASE-amd64.iso.gz && tar -zxvf pfSense-LiveCD-2.0.3-RELEASE-amd64.iso.gz -C pfsense/amd64/
 done

yes | cp -Rv pfsense/*  BSD/Pfsense/

mv pfsense/ tars/

## MENU
touch pxelinux/pfsense.cfg

cat >> pxelinux.cfg/bsd << EOF


menu include pxelinux.cfg/graphics.conf
MENU BACKGROUND pxelinux.cfg/background.png


MENU BEGIN oses-submenu
 LABEL Previous
        MENU LABEL Previous Menu
        TEXT HELP
        Return to previous menu
        ENDTEXT
        MENU EXIT
 MENU TITLE Install PfSense
MENU INCLUDE pxelinux.cfg/pfsense.cfg
MENU END

EOF


    for ARCH in i386 amd64; do
        echo "label Install Pfsense ${ARCH}"
        echo "      menu label Pfsense ${ARCH}"
        echo "      kernel BSD/Pfsense/${ARCH}/vmlinuz"
        echo "      append initrd=BSD/Pfsense/${ARCH}/initrd.img"

echo " "
	echo " TEXT HELP"
       echo "  Install PfSense ${ARCH}"
        echo " ENDTEXT"

   
done >> pxelinux.cfg/pfsense.cfg

